from django import forms
from django.utils.translation import ugettext_lazy as _, ungettext_lazy
from utils import dynforms

from random import shuffle

#
_('Append Field')
ungettext_lazy('Give at most %(limit_value)s choice.', #!! will this work?
'Give at most %(limit_value)s choices.', 3) % dict(limit_value=3)
ungettext_lazy('Give at least %(limit_value)s choice.', #!! will this work?
'Give at least %(limit_value)s choices.', 3) % dict(limit_value=3)#
#

class Create(forms.Form):
    question = forms.CharField(150, label=_('Question'))
    choices = dynforms.ClonerField(forms.CharField(150),
                                   5, 30, 2, label=_('Choices'))
    
def vote_ff(poll):
    choices = [(c.key().id(), c.choice) for c in poll.ordered_choices()]
    shuffle(choices)
    class Vote(forms.Form):
        choice = forms.TypedChoiceField(choices, coerce=int,
                                        label=_('Choice'), widget=forms.RadioSelect)
    return Vote

#XX class SettingsForm(forms.Form):
#    pass
# Define before this a per-user-instantiated model
# called Settings.